package com.su02.multi.examples.mlp;

import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;

public final class GlobalIdHolder {
    private static final AtomicInteger ID = new AtomicInteger();

    public static int nextId() {
        return ID.getAndIncrement();
    }

    public static Iterator<Integer> iterator() {
        return new Iterator<>() {
            @Override
            public boolean hasNext() {
                return ID.get() <= Integer.MAX_VALUE;
            }

            @Override
            public Integer next() {
                return nextId();
            }
        };
    }
}
